package com.ruoyi.wechat.domain.form;

import com.ruoyi.wechat.domain.AttachItem;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * <p>
 * 下单对象
 * </p>
 *
 * @author YinHeng
 * @since 2024/2/29
 */
@Data
public class PlaceForm {
    /**
     * 配送下单
     */
    public interface PickPlace {
    }

    /**
     * 服务下单
     */
    public interface ServPlace {
    }

    /**
     * 商品下单
     */
    public interface ItemPlace {
    }


    /**
     * 购物车商品
     */
    @Valid
    @Size(min = 1, message = "请选择商品", groups = {PickPlace.class, ServPlace.class, ItemPlace.class})
    private List<Item> items;
    /**
     * 商品本体附加服务列表
     */
    private List<AttachItem> productAttachList;
    /**
     * 收获地址id
     */
    @NotNull(message = "收货地址为空", groups = {PickPlace.class, ServPlace.class, ItemPlace.class})
    private Long addrId;
    /**
     * 用户消费券ID
     */
    private Long userCouponId;

    /**
     * 入户密码
     */
    private String intoPwd;
    /**
     * 配送方式,1：有人在家，敲门、2：无人在家，放门口、3：入户密码、4：预约时间、0：其他
     */
    @NotNull(message = "请选择配送方式", groups = {PickPlace.class})
    private Integer delvMode;
    /**
     * 预约时间
     */
    private String aptTime;
    /**
     * 标识，0：正常订单，1：加急订单
     */
    @NotNull(message = "请选择是否加急", groups = PickPlace.class)
    private Integer tag;
    /**
     * 附加说明
     */
    private String attachText;
    /**
     * 附加文件列表
     */
    private List<String> attachFileList;
    /**
     * 订单备注
     */
    private String remark;


    @Data
    public static class Item {
        /**
         * 商品ID
         */
        @NotNull(message = "商品id为空", groups = {PickPlace.class, ServPlace.class, ItemPlace.class})
        private Long id;
        /**
         * 商品规格ID
         */
        @NotNull(message = "规格id为空", groups = {PickPlace.class, ServPlace.class, ItemPlace.class})
        private Long specId;
        /**
         * 商品数量
         */
        @Min(value = 1, message = "数量不得小于1", groups = {PickPlace.class, ServPlace.class, ItemPlace.class})
        private Integer num;

    }
}
